﻿@model BusinessManagementStudio.ViewModel.CompanyOrder

@{
    ViewBag.Title = "Create New Order";
    TempData.Keep();
}

<title>JLL Order Creation</title>

<h2 align="center">Create New Order For 7. JLL ORDER</h2>

@using (Html.BeginForm("Switch", "Order", FormMethod.Post))
{

    <div align="center">Select A Company @Html.DropDownList("Company", Model.company.CompanyNameList, null, new
                                    {
                                        title = "Pick Batch",
                                        onchange = "submit();"
                                    })</div>
}

@using (Html.BeginForm("MultipleCommand", "Order", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)

    <table align="center">
        <tr>
            <td width="120">Select Excel File :</td>
            <td><input type="file" name="file"/></td>
        </tr>
        <tr></tr>
        <tr>
            <td></td>
            <td><button type="submit" name="Command" value="Upload Excel">Upload Excel</button></td>
        </tr>
        <tr>
            <td></td>
            <td><button type="submit" name="Command" value="BackToMainMenu">Back To Main Menu</button></td>
        </tr>
    </table>
    <br align="center"/>
    
    if (Model.orderList != null)
    {
        <table align="center" border="1">
            <thead>
                <tr>
                    <th width="100">Service Order No.</th>
                    <th width="300">Description</th>
                    <th width="120">Location</th>
                    <th width="100">Work Order No.</th>
                    <th width="80">Emergency</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.orderList)
                {
                    <tr>
                        <td align="center">@item.ServiceOrderNo</td>
                        <td>@item.Description</td>
                        <td>@item.Location</td>
                        <td align="center">@item.WorkOrderNo</td>
                        <td align="center">@item.Emergency</td>
                    </tr>
                }
            </tbody>
        </table>
        <table align="center">
            <tr>
                <td width="100"></td>
                <td width="300"></td>
                <td width="120"></td>
                <td width="100" align="left">Total Number</td>
                <td width="80" align="center">@Html.DisplayFor(model => model.orderList.Count)</td>
            </tr>
        </table>
        <br align="center"/>
        <div align="center">
            <button type="submit" name="Command" value="Confirm">Confirm</button>
            <button type="submit" name="Command" value="Cancel">Cancel</button>
            <button type="submit" name="Command" value="Clear">Clear</button> 
        </div>
    }
}

<link href='~/Scripts/jquery-ui.css' rel='stylesheet'>
<script type="text/javascript" src="~/Scripts/jquery-2.1.0.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui.js"></script>
<script type="text/javascript" src="~/Scripts/knockout-3.0.0.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.min.js"></script>
<script type="text/javascript">
    function HandleBrowseClick() {
        var fileinput = document.getElementById("browse");
        fileinput.click();
    }
    function Handlechange() {
        var fileinput = document.getElementById("browse");
        var textinput = document.getElementById("filepath");
        textinput.value = fileinput.value;
    }
//    $(document).ready(function () {
//        $('#btn_Cancel').click(function () {
//            var enteredData = document.getElementById("filepath");
//            $.post("/Order/Index", { FileNameWithFakePath: enteredData }, function (data) {
//                $('#Result').text(data.Text);
//            }, "json");
//        });
//    });
//    $(function () {
//        $('#btn_Upload').click(function () {
//            jConfirm('Confirm to upload?', 'Confirmation Dialog', function (r) {
//                if (r) {
//                    $("form").submit();
//                }
//            });
//        });
        //    });
</script>